var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2DataManager = require("DataManager");
var $2EventsMgr = require("EventsMgr");
var $2UserDataManager = require("UserDataManager");
var $2Jiangshibwz = require("Jiangshibwz");
var $2DfbwzhUI = require("DfbwzhUI");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var h;
(function (e) {
  e[e.norm = 0] = "norm";
  e[e.tiao = 1] = "tiao";
  e[e.likai = 2] = "likai";
  e[e.tiao_end = 3] = "tiao_end";
})(h || (h = {}));
var def_Role1 = /* */function (_cc$Component62) {
  babel_inherits(u, _cc$Component62);
  var _super78 = babel_createSuper(u);
  function u() {
    var _this176;
    babel_classCallCheck(this, u);
    _this176 = _super78.apply(this, arguments);
    _this176.hp_role = 0;
    _this176.hp_total = 0;
    _this176.hp = null;
    _this176.sheji_hurt = 0;
    _this176.lunqiang_hurt = 0;
    _this176.xuli_hurt = 0;
    _this176.flag = h.norm;
    _this176.role_y = -165;
    return _this176;
  }
  babel_createClass(u, [{
    key: "start",
    value: function start() {
      this.hp = cc.find("hp", this.node);
      this.hp.active = false;
      this.hp_total = this.hp_role = $2UserDataManager.default.instance.bwzdaifuInfo[0].value;
      this.sheji_hurt = $2UserDataManager.default.instance.bwzdaifuInfo[1].value;
      this.lunqiang_hurt = $2UserDataManager.default.instance.bwzdaifuInfo[2].value;
      this.xuli_hurt = $2UserDataManager.default.instance.bwzdaifuInfo[3].value;
    }
  }, {
    key: "setHp",
    value: function setHp(e) {
      this.hp_role -= e.getComponent($2Jiangshibwz.default).atk;
      if (this.hp_role <= 0) {
        this.hp_role = 0;
        this.hp.getComponent(cc.ProgressBar).progress = this.hp_role / this.hp_total;
        return void this.node.parent.getComponent($2DfbwzhUI.default).game_over();
      }
      this.hp.getComponent(cc.ProgressBar).progress = this.hp_role / this.hp_total;
    }
  }, {
    key: "onCollisionEnter",
    value: function onCollisionEnter(e, t) {
      this.flag = h.norm;
    }
  }, {
    key: "onCollisionExit",
    value: function onCollisionExit(e, t) {
      "fd0" != e.node.name && "fd1" != e.node.name && "fd2" != e.node.name || this.flag != h.tiao && (this.flag = h.likai);
    }
  }, {
    key: "onCollisionStay",
    value: function onCollisionStay(e, t) {
      "fd0" != e.node.name && "fd1" != e.node.name && "fd2" != e.node.name || this.flag != h.tiao && (this.flag = h.norm);
    }
  }, {
    key: "is_over",
    value: function is_over() {
      if (!$2DataManager.default.instance.is_over) {
        $2DataManager.default.instance.is_over = true;
        cc.tween(this.node).to(.3, {
          position: cc.v3(this.node.x, this.node.y - 300)
        }, {
          easing: "easeInQuint"
        }).call(function () {
          $2EventsMgr.EventsManager.emit("game_over");
        }).start();
      }
    }
  }, {
    key: "check_down",
    value: function check_down() {
      if (this.flag != h.tiao) {
        this.flag == h.likai && this.is_over();
        this.flag == h.tiao_end && this.is_over();
      }
    }
  }, {
    key: "update",
    value: function update(e) {
      $2DataManager.default.instance.is_over || this.check_down();
    }
  }]);
  return u;
}(cc.Component);
def_Role1 = cc__decorate([ccp_ccclass], def_Role1);
exports.default = def_Role1;